home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
Issue57
/
alfresco
/
tststr2.dpr
< prev
next >
Wrap
Text File
|
2000-04-08
|
1KB
|
57 lines
program tststr2;
{$APPTYPE CONSOLE}
uses
Windows,
SysUtils;
function PosCh(aCh : char; const S : string; aStart : integer) : integer;
var
i : integer;
begin
if (aStart < 1) then
aStart := 1;
for i := aStart to length(S) do
if (S[i] = aCh) then begin
Result := i;
Exit;
end;
Result := 0;
end;
function PosChNormal(aCh : char; const S : string) : integer;
begin
Result := Pos(aCh, S);
end;
var
i : integer;
StartTime : DWORD;
begin
writeln(PosCh('a', 'The cat sat on the mat'));
writeln(PosCh('b', 'The cat sat on the mat'));
writeln(PosCh('c', 'The cat sat on the mat'));
writeln(PosCh('m', 'The cat sat on the mat'));
writeln('testing normal routine...');
StartTime := GetTickCount;
for i := 1 to 10000000 do
PosChNormal('j', 'The cat sat on the mat');
writeln('time taken: ', GetTickCount - StartTime);
writeln('testing pascal routine...');
StartTime := GetTickCount;
for i := 1 to 10000000 do
PosChPascal('j', 'The cat sat on the mat');
writeln('time taken: ', GetTickCount - StartTime);
writeln('testing assembly routine...');
StartTime := GetTickCount;
for i := 1 to 10000000 do
PosCh('j', 'The cat sat on the mat');
writeln('time taken: ', GetTickCount - StartTime);
readln;
end.